<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>地理位置接口</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
          <div class="layui-card-header">地理位置接口
					{if input('param.isopen')==1}<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>{/if}</div>
          <div class="layui-card-body" pad15>
						
						<div class="layui-col-md12">
							<table id="tabledata" lay-filter="tabledata"></table>
						</div>
          </div>
        </div>
    </div>
  </div>
	{include file="public/js"/}
	<script>
  var table = layui.table;
	var datawhere = {};
  //数据表
  var tableIns = table.render({
    elem: '#tabledata'
    ,url: "{$Request.url}" //数据接口
    ,page: false //开启分页
    ,cols: [[
      {field: 'api_name', title: '接口'},
      {field: 'api_ch_name', title: '接口名称'},
      {field: 'api_desc', title: '接口描述'},
      {field: 'status', title: '状态',templet:function(d){ 
				if(d.status == 1){
					return '<span>未开通</span>';
				}
				if(d.status == 2){
					return '<span>无权限</span>';
				}
				if(d.status == 3){
					return '<span style="color:blue">申请中</span>';
				}
				if(d.status == 4){
					return '<span style="color:red">未通过</span><br><span style="color:red">'+d.fail_reason+'</span>';
				}
				if(d.status == 5){
					return '<span style="color:green">已开通</span>';
				}
			}},
      {field: 'operation', title: '操作',templet: function(d){
				var html = '';
				if(d.status!=5){
					html += '<button class="table-btn" onclick="apply(\''+d.api_name+'\')">申请开通</button>';
				}
				html += '<a class="table-btn" style="padding:5px 10px" href="'+d.api_link+'" target="_blank">查看文档</a>';
				return html;
      }}
    ]]
  });
	//排序
	table.on('sort(tabledata)', function(obj){
		datawhere.field = obj.field;
		datawhere.order = obj.type;
		tableIns.reload({
			initSort: obj,
			where: datawhere
		});
	});
	//检索
	layui.form.on('submit(LAY-app-forumreply-search)', function(obj){
		var field = obj.field
		var olddatawhere = datawhere
		datawhere = field
		datawhere.field = olddatawhere.field
		datawhere.order = olddatawhere.order
		tableIns.reload({
			where: datawhere,
			page: {curr: 1}
		});
	})
	
	function apply(api_name){
		var html = '<div style="margin:20px" class="layui-form form-label-w8">';
		
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label">申请原因：</label>';
		html+='	<div class="layui-input-inline" style="width:400px">';
		html+='		<textarea type="text" name="info[content]" class="layui-textarea" style="height:100px" placeholder="详细描述接口能力的具体使用场景\r\n如：因当前业务涉及外卖送餐服务，需获取用户地理位置信息。"></textarea>';
		html+='	</div>';
		html+='</div>';
		
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label">辅助图片（选填）：</label>';
		html+='	<input type="hidden" name="info[pic_list]" value="" id="pics">';
		html+='	<button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this,true)" upload-input="pics" upload-preview="picList">上传图片</button>';
		html+='	<div class="layui-form-mid layui-word-aux" style="margin-left:20px;">可上传小程序截图，最多上传10张图片，图片大小不超过5M。</div>';
		html+='	<div id="picList" style="float:left;padding-top:10px;padding-left:170px;clear: both;">';
		html+='	</div>';
		html+='</div>';
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label">辅助视频（选填）：</label>';
		html+='	<div class="layui-input-inline" style="width:400px">';
		html+='		<input type="text" name="info[video]" id="video" lay-verType="tips" class="layui-input" value="">';
		html+='	</div>';
		html+='	<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="video" onclick="uploader(this)">上传视频</button>';
		html+='	<div class="layui-form-mid layui-word-aux" style="margin-left:170px;">可上传小程序使用录屏，最多上传1个视频。视频支持mp4格式，视频大小不超过20M。</div>';
		html+='</div>';
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label">辅助网页（选填）：</label>';
		html+='	<div class="layui-input-inline" style="width:400px">';
		html+='		<input type="text" name="info[url]" value="" class="layui-input"/>';
		html+='	</div>';
		html+='	<div class="layui-form-mid layui-word-aux" style="margin-left:170px;">可填写官网链接协助审核</div>';
		html+='</div>';
		html+='<div class="layui-form-item" style="margin-top:30px">';
		html+='	<label class="layui-form-label"></label>';
		html+='	<div class="layui-input-inline">';
		html+='		<button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit_apply">确 定</button>';
		html+='	</div>';
		html+='</div>';
		html+='</div>';
		var applyLayer = layer.open({type:1,area:['800px','600px'],content:html,title:'申请接口 '+api_name,shadeClose:true});
		layui.form.on('submit(submit_apply)', function(obj){
			var field = obj.field;
			field['info[api_name]'] = api_name;
			var index = layer.load();
			$.post("{:url('applyPrivacyInterface')}",field,function(data){
				layer.close(index);
				dialog(data.msg,data.status);
				if(data.status == 1){
					layer.close(applyLayer);
					tableIns.reload()
				}
			});
		});
	}
	</script>
	{include file="public/copyright"/}
</body>
</html>